package com.ruixin.base.util;

import com.sun.istack.internal.NotNull;

/**
 * Created by Ruixin
 * Description:String工具类
 */
public class StringUtil {

    //判断String是否为空
    public static boolean isBlackOrNull(Object object){
        if(object == null){
            return true;
        }
        return object.equals("");
    }

    public static boolean isNotBlackOrNull(Object object){
        return !isBlackOrNull(object);
    }

    /**
     * 数组转String
     * @param objects
     * @param splitChar
     * @return
     */
    public static String join(@NotNull Object[] objects, @NotNull String splitChar){
        StringBuilder builder = new StringBuilder();
        for (Object object : objects) {
            builder.append(splitChar).append(object);
        }
        if(builder.length()>0){
            return builder.substring(1);
        }
        return "";
    }

    public static String toString(Object object){
        if(object==null){
            return null;
        }
        return object.toString();
    }
}
